package com.wsx.ones.monitor.core.netty;

import com.wsx.ones.monitor.core.serialize.RpcSerializeProtocol;
import com.wsx.ones.monitor.core.serialize.hession.HessionMessageCodec;
import com.wsx.ones.monitor.core.serialize.hession.HessionMessageDecoder;
import com.wsx.ones.monitor.core.serialize.hession.HessionMessageEncoder;
import io.netty.channel.ChannelPipeline;

import java.util.concurrent.ConcurrentHashMap;

/**
 * netty服务端通道的核心实现类
 *
 * Created by wangshuaixin on 17/2/7.
 */
public class PullPipelineFrame {

    public PullPipelineFrame () {

    }

    /**
     *
     * @param protocol
     * @param pipeline
     * @param rpcBeanMap
     */
    public void initPipeline(RpcSerializeProtocol protocol, ChannelPipeline pipeline, ConcurrentHashMap<String, Object> rpcBeanMap) {
        switch (protocol) {
            case HESSIONSERIALIZE:
                HessionMessageCodec codec = new HessionMessageCodec();
                pipeline.addLast(new HessionMessageDecoder(codec));
                pipeline.addLast(new HessionMessageEncoder(codec));
                pipeline.addLast(new PullMessageHander(rpcBeanMap));
                break;
            case KRYOSERIALIZE:
                break;
        }
    }
}
